package com.xhu.collegestudentrentalsystem;

import com.xhu.collegestudentrentalsystem.module.user.service.IOrderService;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

@SpringBootApplication
@MapperScan({"com.xhu.collegestudentrentalsystem.module.user.dao","com.xhu.collegestudentrentalsystem.module.manager.dao"})
@EnableScheduling
public class CollegestudentrentalsystemApplication {

    @Autowired
    private IOrderService orderService;

    public static void main(String[] args) {
        SpringApplication.run(CollegestudentrentalsystemApplication.class, args);
    }

    // 定时任务，每天执行一次，检查数据库中order表是否有过期订单，如果有，将它们修改为过期状态
    @Scheduled(cron = "0 10 0 ? * *")
    public void updateOrderToExpired(){
        orderService.findAndUpdateExpiredOrder();
    }

}
